package cn.kn.sys.controller;

import cn.kn.common.model.PageBean;
import cn.kn.common.model.R;
import cn.kn.sys.service.RoleService;
import cn.kn.sys.vo.RoleVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author WangJiang
 * @create 2020-12-04 15:38
 */

@RestController
@RequestMapping("sys/role")
@RequiredArgsConstructor
public class RoleController {
    private final RoleService roleService;

    @GetMapping("all")
    public R all(){
        return roleService.all();
    }

    @GetMapping
    public R list(String name,  PageBean pageBean){
        return roleService.list(name,pageBean);
    }


    @PostMapping
    public R add(@RequestBody RoleVo roleVo){
        return roleService.add(roleVo);
    }


    @DeleteMapping("/{id}")
    public R del(@PathVariable Long id){
        return roleService.del(id);
    }

    @PutMapping("/{id}")
    public R edit(@PathVariable Long id,@RequestBody RoleVo roleVo){
        return roleService.edit(id,roleVo);
    }

    @PutMapping("/{id}/{isstop}")
    public R editStatus(@PathVariable Long id,@PathVariable Boolean isstop){
        return roleService.editStatus(id,isstop);
    }
}
